from public.action import *
from public.tools import *
from public.testData import *
testCase = "DBshop0011_添加商品"
firefox=getDriver()
openBrowser(firefox,urlAdmin)
logInAdmin(firefox)

adminMenu2(firefox,"商品管理","管理商品")
# 1.点击添加商品按钮，商品名称填写“苹果XR”,本店价格“7999”，商品类型“虚拟商品”。
firefox.find_element_by_partial_link_text("添加商品").click()
firefox.find_element_by_id("goods_name").send_keys("苹果XR")
firefox.find_element_by_id("goods_shop_price").send_keys("7999")
firefox.find_element_by_xpath("//select[@id='goods_type']/option[3]").click()
# 2.点击“保存商品”按钮，后台保存成功添加的商品。
firefox.find_element_by_xpath("//button[@type='submit']").click()
time.sleep(2)

s=firefox.find_element_by_xpath("//table/tbody/tr[2]/td[3]").text
print(s)
#断言
try:
    firefox.find_element_by_xpath("//td[contains(.,'苹果XR')]").is_displayed()
    writeLog("%s 测试通过" % testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()


